package com.ruoyi.system.outto.game.impl;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.GlobalException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.system.model.domain.AccountInfo;
import com.ruoyi.system.model.domain.InfoImg;
import com.ruoyi.system.model.domain.SalePartner;
import com.ruoyi.system.model.mapper.InfoImgMapper;
import com.ruoyi.system.outto.core.LCConstant;
import com.ruoyi.system.outto.core.MapUntils;
import com.ruoyi.system.outto.core.OutUrlConstant;
import com.ruoyi.system.outto.game.CommonApi;
import com.ruoyi.system.outto.game.IPANZHIAPI;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @Author sdq
 * @Date 2022/7/5 10:27
 */
@Slf4j
@Service
public class PANZHIImpl implements IPANZHIAPI {
    private static final String PZ_ADD_URL = "/api/openData/dataSync";
    private static final String PZ_MOD_URL = "/api/openData/updateGoodsPrice";
    private static final String PZ_DEL_URL = "/api/openData/downStandGoods";
    private static final String PZ_PROXY_ID = "15225247351";
//    private static final String PZ_PROXY_ID = "18641279369";

//    private static final String PZ_PROXY_ID = "19153321403";
    @Resource
    private InfoImgMapper infoImgMapper;
    @Autowired
    private CommonApi commonApi;
    @Value("${desc.title}")
    private String descTitle;

    public static String getCover(Map<String,Object> params){
        StringBuffer resut = new StringBuffer();
        for (String key : params.keySet()) {
            if(params.get(key) instanceof String && StringUtils.isNotEmpty((String)params.get(key))){
                resut.append(key+"="+params.get(key)+"&");
            }
            if(params.get(key) instanceof Boolean){
                resut.append(key+"="+params.get(key)+"&");
            }
            if(params.get(key) instanceof Long){
                resut.append(key+"="+params.get(key)+"&");
            }
            if(params.get(key) instanceof Integer && null != params.get(key)){
                resut.append(key+"="+params.get(key)+"&");
            }
        }
        return resut.toString();
    }

    private Map<String,Object> params(AccountInfo accountInfo, SalePartner sa){
        Map<String,Object> params = new HashMap<>();
        params.put("proxyId",null == sa.getOther() ? PZ_PROXY_ID : sa.getOther());
        Map<String,Object> action = new TreeMap<>();
        action.put("linkPhone","13845678901");
        action.put("linkQq","13845678901");
        action.put("linkWx","13845678901");
        action.put("goodsCatalogueId",6);
        action.put("gameAccount",null == accountInfo.getAccountId()?"123456789":accountInfo.getAccountId());
        action.put("gameSecret",null == accountInfo.getAccountId()?"123456789":accountInfo.getAccountId());
        action.put("accountSource","BUY_PRIVATE");
        action.put("title","【"+descTitle + "_" + accountInfo.getId() + "】  "+ accountInfo.getLevel() + "  " + accountInfo.getDes());//商品标题
        action.put("goodsImg",null != accountInfo.getTitleImg() ? accountInfo.getTitleImg():"https://game.ikbh.top/logo/no_img.jpg");
        if (accountInfo.getPrice().compareTo(new BigDecimal(1000)) < 0){
            throw new GlobalException("价格太低，不推送");
        }else {
            BigDecimal bigDecimal = commonApi.addPrice(accountInfo.getPrice(), sa.getSeleep());
            commonApi.setPrice(bigDecimal,accountInfo.getId(),sa);
            action.put("price",bigDecimal.stripTrailingZeros().toPlainString());
        }

        action.put("description",accountInfo.getDes());
        action.put("shotType","ONESELF");
        action.put("compensation",true);
        action.put("bargain",true);
        action.put("outGoodsNo",accountInfo.getId().toString());
        action.put("sellRange","ALL");
        action.put("gameSecret","123456");
        action.put("detailsImages",new String[]{"https://game.ikbh.top/logo/no_img.jpg"});

        InfoImg infoImg = new InfoImg();
        infoImg.setInfoId(accountInfo.getId());
        infoImg.setType(Constants.STR_1);
        List<InfoImg> infoImgs = infoImgMapper.selectInfoImgList(infoImg);
        if(!CollectionUtils.isEmpty(infoImgs)){
            action.put("detailsImages",infoImgs.stream().map(InfoImg::getImgUrl).collect(Collectors.toList()).toArray());
        }

        if("王者荣耀".equals(accountInfo.getType())){
            action = wzryParams(accountInfo,action);
        }else if("和平精英".equals(accountInfo.getType())){
            action.put("gameId",8);
            if("有二次".equals(accountInfo.getLevel())){
                action.put("single4",2167);
            }else if("包人脸".equals(accountInfo.getLevel())){
                action.put("single4",2562);
            }else{
                action.put("single4",2168);
            }
            String regional = accountInfo.getRegional();
            if("安卓Q".equals(regional)){
                action.put("single1",264);//操作系统
            }else if("苹果Q".equals(regional)){
                action.put("single1",265);//操作系统
            }else if("安卓WX".equals(regional)){
                action.put("single1",266);//操作系统
            }else if("苹果WX".equals(regional)){
                action.put("single1",267);//操作系统
            }else{
                action.put("single1",1600);//操作系统
            }

            action.put("detailsCheckbox1",new String[]{"1759"});
            action.put("detailsSingle1",1331);
            action.put("detailsText3",null == accountInfo.getCampId()?"123":accountInfo.getCampId());
        }else if("英雄联盟".equals(accountInfo.getType())){
            action.put("section2",null == accountInfo.getSkins() ? 0:accountInfo.getSkins());
            action.put("section1",0);
            action.put("gameId",6);
            action.put("single1",1003);
            action.put("single2",1004);
            action.put("detailsSingle1",1318);
            action.put("detailsSingle4",2586);
            if("有二次".equals(accountInfo.getLevel()) || "包人脸".equals(accountInfo.getLevel())){
                action.put("detailsSingle3",2564);
            }else{
                action.put("detailsSingle3",2566);
            }
        }else if("原神".equals(accountInfo.getType())){
            action.put("gameId",12);
            action.put("single1",1082);
            action.put("single2",1083);
            action.put("single4",1282);
            action.put("single5",1284);
            action.put("single6",1286);
            action.put("single7",2532);
            action.put("single8",3512);
            action.put("detailsSingle1",1339);
        }else if("CF端游".equals(accountInfo.getType())){
            action.put("gameId",16);
            if (Objects.equals("东部大区",accountInfo.getRegional())){
                action.put("single1",900);
            }
            if (Objects.equals("南部大区",accountInfo.getRegional())){
                action.put("single1",901);
            }
            if (Objects.equals("西部大区",accountInfo.getRegional())){
                action.put("single1",902);
            }
            if (Objects.equals("北部大区",accountInfo.getRegional())){
                action.put("single1",903);
            }
            action.put("single2",1090);
            action.put("gameAccount",accountInfo.getExtractAccount());
            action.put("accountSource","ORIGINAL_USER");
            action.put("detailsSingle1","1352");
            if (Arrays.asList(LCConstant.haveTwoList).contains(accountInfo.getLevel())){
                action.put("detailsSingle2","2551");
                action.put("single5","5839");
            }else {
                action.put("detailsSingle2","2552");
                action.put("single5","5840");
            }

            if (LCConstant.bakFace.equals(accountInfo.getLevel())){
                action.put("single5","5839");
            }
            if (LCConstant.noTwo.equals(accountInfo.getLevel())){
                action.put("single5","5840");
            }

            action.put("title",accountInfo.getDes());
            action.put("goodsImg",accountInfo.getTitleImg());
            action.put("description",accountInfo.getDes());
            action.put("shotType","ONESELF");
            action.put("single4","4834");
            action.put("outGoodsNo",accountInfo.getId());
            action.put("goodsCatalogueId",6);
            action.put("bargain",true);
            action.put("compensation",true);
        }else if("CF手游".equals(accountInfo.getType())){
            action.put("gameId",10);
            action.put("gameAccount",accountInfo.getExtractAccount());
            action.put("accountSource","ORIGINAL_USER");

            action.put("single2",1090);
            action.put("detailsSingle1","1334");
            if (Arrays.asList(LCConstant.haveTwoList).contains(accountInfo.getLevel())){
                action.put("detailsSingle2","2551");
            }else {
                action.put("detailsSingle2","2552");
            }
            action.put("title",accountInfo.getDes());
            action.put("goodsImg",accountInfo.getTitleImg());

            action.put("description",accountInfo.getDes());

            action.put("shotType","ONESELF");
            action.put("single4","4834");
            action.put("outGoodsNo",accountInfo.getId());
            action.put("goodsCatalogueId",6);
            action.put("bargain",true);
            action.put("compensation",true);
            String regional = accountInfo.getRegional();
            if("安卓Q".equals(regional)){
                action.put("single1",526);//操作系统
            }else if("苹果Q".equals(regional)){
                action.put("single1",527);//操作系统
            }else if("安卓WX".equals(regional)){
                action.put("single1",528);//操作系统
            }else if("苹果WX".equals(regional)){
                action.put("single1",529);//操作系统
            }else{
                action.put("single1",1600);//操作系统
            }
            action.put("single1",6);
        }else if("逆战".equals(accountInfo.getType())){
            action.put("gameId",14);
            action.put("gameAccount",accountInfo.getExtractAccount());
            action.put("accountSource","ORIGINAL_USER");

            action.put("single2",1090);
            action.put("detailsSingle1","1334");
            if (Arrays.asList(LCConstant.haveTwoList).contains(accountInfo.getLevel())){
                action.put("detailsSingle2","2551");
            }else {
                action.put("detailsSingle2","2552");
            }
            action.put("title",accountInfo.getDes());
            action.put("goodsImg",accountInfo.getTitleImg());

            action.put("description",accountInfo.getDes());

            action.put("shotType","ONESELF");
            action.put("single4","4834");
//            action.put("goodsNo",accountInfo.getId());
            action.put("outGoodsNo",accountInfo.getId());
            action.put("goodsCatalogueId",6);
            action.put("bargain",true);
            action.put("compensation",true);
            String regional = accountInfo.getRegional();
            if (Objects.equals("网通",accountInfo.getRegional())){
                action.put("single1",896);//操作系统
            }
            if (Objects.equals("电信",accountInfo.getRegional())){
                action.put("single1",895);//操作系统
            }
            action.put("single1",6);
        }else if("火影忍者".equals(accountInfo.getType())){
            action.put("gameId",11);
            action.put("shotType","ONESELF");
            action.put("outGoodsNo",accountInfo.getId());
            action.put("detailsSingle1","1337");
            String regional = accountInfo.getRegional();
            if("安卓Q".equals(regional)){
                action.put("single1",530);//操作系统
            }else if("苹果Q".equals(regional)){
                action.put("single1",531);//操作系统
            }else if("安卓WX".equals(regional)){
                action.put("single1",532);//操作系统
            }else if("苹果WX".equals(regional)){
                action.put("single1",533);//操作系统
            }else{
                action.put("single1",1600);//操作系统
            }
        }else if("永劫无间".equals(accountInfo.getType())){
            action.put("gameId",2);
            action.put("shotType","ONESELF");
            action.put("outGoodsNo",accountInfo.getId());
            action.put("detailsSingle1","1293");
            action.put("detailsSingle3","1463");

            String regional = accountInfo.getRegional();
            if("steam".equals(regional)){
                action.put("detailsSingle2",3794);
            }else if("EPIC".equals(regional)){
                action.put("detailsSingle2",3795);//操作系统
            }else if("网易".equals(regional)){
                action.put("detailsSingle2",3792);//操作系统
            }
            if("网易".equals(regional)){
                action.put("single1",31);//操作系统
            }else if("steam".equals(regional)){
                action.put("single1",32);//操作系统
            }else if("EPIC".equals(regional)){
                action.put("single1",2531);//操作系统
            }
        }else{
            throw new GlobalException("盼之接口不支持此游戏：" + accountInfo.getType());
        }
        params.put("action",action);
        params.put("timestamp",System.currentTimeMillis()+"");
        String cover = getCover(action) +"timestamp=" + params.get("timestamp").toString() + "&key="+sa.getSaleKey();
        log.info("cover={}",cover);
        String sign = DigestUtils.md5Hex(cover).toUpperCase();
        params.put("sign",sign);
        return params;
    }
    private Map<String,Object> wzryParams(AccountInfo accountInfo, Map<String,Object> action){
        action.put("gameId",7);
        action.put("detailsText1",null == accountInfo.getCampId()?"123":accountInfo.getCampId());
        action.put("detailsSection1",8);
        if("有二次".equals(accountInfo.getLevel())){
            action.put("single4",2164);
        }else if("包人脸".equals(accountInfo.getLevel())){
            action.put("single4",2561);
        }else{
            action.put("single4",2165);
        }
        action.put("section2",0);//荣耀水晶数
        action.put("section1",null == accountInfo.getSkins() ? 0:accountInfo.getSkins());// 皮肤数
        //1466金色仲夏夜1467幽冥之眼1468幽冥火1469幻海之心1470未来机甲1471零号雷霆1475时之愿境2560无
        action.put("detailsCheckbox2",new String[]{"2560"});
        //3514 皮肤1 3515皮肤2 3516皮肤3 3517皮肤4
        action.put("detailsCheckbox1",new String[]{"3514"});//星元皮肤1
        //安卓Q 苹果Q 安卓WX 苹果WX
        String regional = accountInfo.getRegional();
        if("安卓Q".equals(regional)){
            action.put("single1",246);//操作系统
        }else if("苹果Q".equals(regional)){
            action.put("single1",247);//操作系统
        }else if("安卓WX".equals(regional)){
            action.put("single1",248);//操作系统
        }else if("苹果WX".equals(regional)){
            action.put("single1",249);//操作系统
        }else{
            action.put("single1",1600);//操作系统
        }
        action.put("single2",1600);//服务器 获取不到 默认赋值1600
        action.put("detailsSingle1",1328);
        return action;
    }
    @Override
    public AjaxResult addGame(AccountInfo accountInfo, Long userId, SalePartner salePartner) {
        Map<String, Object> params = params(accountInfo,salePartner);
        String paramsStr = JSONObject.toJSONString(params);
        log.info("盼之新增请求参数={}",paramsStr);
        String response = HttpUtils.sendPost(OutUrlConstant.PANZHIURL+PZ_ADD_URL, paramsStr, "application/json");
        log.info("盼之新增返回参数={}",response);
        JSONObject resultJson = JSONObject.parseObject(response);
        String msg = resultJson.getString("info");
        msg = MapUntils.unicodeToString(msg);
//        if (!resultJson.getBoolean("success")){
//            throw new GlobalException(msg);
//        }
        Map<String, Object> result = new HashMap<>();

        if (!resultJson.getBoolean("success")){
            result.put("code",500);
        }else {
            result.put("code",200);
        }
        result.put("req",JSONObject.toJSONString(params));
        result.put("res",response);
        result.put("msg",msg);
        return AjaxResult.success(result);
    }

    @Override
    public AjaxResult editGame(AccountInfo accountInfo, Long userId,SalePartner sa) {

        Map<String,Object> action = new TreeMap<>();
        action.put("outGoodsNo",accountInfo.getId().toString());
        if (accountInfo.getPrice().compareTo(new BigDecimal(1000)) < 0){
            throw new GlobalException("价格太低，不推送");
        }else {
            BigDecimal bigDecimal = commonApi.addPrice(accountInfo.getPrice(), sa.getSeleep());
            commonApi.setPrice(bigDecimal,accountInfo.getId(),sa);
            action.put("price",bigDecimal.stripTrailingZeros().toPlainString());
        }
        action.put("remark","修改");
        Map<String,Object> params = new HashMap<>();
        params.put("proxyId",null == sa.getOther() ? PZ_PROXY_ID : sa.getOther());
        params.put("action",action);
        params.put("timestamp",System.currentTimeMillis()+"");

        String cover = getCover(action) +"timestamp=" + params.get("timestamp").toString() + "&key="+sa.getSaleKey();;
        String sign = DigestUtils.md5Hex(cover).toUpperCase();
        params.put("sign",sign);
        String paramsStr = JSONObject.toJSONString(params);

        log.info("盼之修改商品价格请求参数={}",paramsStr);
        String response = HttpUtils.sendPost(OutUrlConstant.PANZHIURL+PZ_MOD_URL, paramsStr, "application/json");
        log.info("盼之修改商品价格返回参数={}",response);
        JSONObject resultJson = JSONObject.parseObject(response);
        String msg = resultJson.getString("info");
        msg = MapUntils.unicodeToString(msg);
//        if (!resultJson.getBoolean("success")){
//            throw new GlobalException(msg);
//        }
        Map<String, Object> result = new HashMap<>();

        if (!resultJson.getBoolean("success")){
            result.put("code",500);
        }else {
            result.put("code",200);
        }
        result.put("req",JSONObject.toJSONString(params));
        result.put("res",response);
        result.put("msg",msg);
        return AjaxResult.success(result);
    }

    @Override
    public AjaxResult delGame(Long id, Long userId, SalePartner sa) {
        Map<String,Object> action = new TreeMap<>();
        action.put("outGoodsNo",id.toString());
        action.put("remark","下架商品");
        Map<String,Object> params = new HashMap<>();
        params.put("proxyId",null == sa.getOther() ? PZ_PROXY_ID : sa.getOther());
        params.put("action",action);
        params.put("timestamp",System.currentTimeMillis()+"");

        String cover = getCover(action) +"timestamp=" + params.get("timestamp").toString() + "&key="+sa.getSaleKey();;
        String sign = DigestUtils.md5Hex(cover).toUpperCase();
        params.put("sign",sign);
        String paramsStr = JSONObject.toJSONString(params);

        log.info("盼之下架请求参数={}",paramsStr);
        String response = HttpUtils.sendPost(OutUrlConstant.PANZHIURL + PZ_DEL_URL, paramsStr, "application/json");
        log.info("盼之下架返回参数={}",response);

        JSONObject resultJson = JSONObject.parseObject(response);
        String msg = resultJson.getString("info");
        msg = MapUntils.unicodeToString(msg);
//        if (!resultJson.getBoolean("success")){
//            throw new GlobalException(msg);
//        }
        Map<String, Object> result = new HashMap<>();

        if (!resultJson.getBoolean("success")){
            result.put("code",500);
        }else {
            result.put("code",200);
        }
        result.put("req",JSONObject.toJSONString(params));
        result.put("res",response);
        result.put("msg",msg);
        return AjaxResult.success(result);
    }

    public static void main(String[] args) {
//        Map<String,Object> params = new HashMap<>();
//        params.put("proxyId","pzdstest");
//        //王者荣耀
//        Map<String,Object> action = new TreeMap<>();
//        action.put("gameAccount","251");//游戏账号 account_id
//        action.put("gameSecret","12345");//游戏密码 ,非必输
//        action.put("detailsText1","王者");//营地号（模糊搜索）
//        // ORIGINAL_USER:原号主 BUY_PZDS:购买自盼之平台 SIX_MONTH:购买自其它平台已满6个月
//        // NO_SIX_MONTH:购买自其它平台未满6个月 BUY_PRIVATE:  私下交易
//        action.put("accountSource","ORIGINAL_USER");//账号来源
//        action.put("detailsSection1",8);//贵族等级 number
//        action.put("title","测试王者荣耀");//商品标题
//        action.put("goodsImg","https://game.ikbh.top/logo/no_img.jpg");//商品封面图 ,
////        action.put("shotRemark","截图备注");//截图备注 , 非必填
//        action.put("price",299);//价格
//        action.put("detailsImages",new String[]{"http://test01.png","http://test01.png"});//详情图数组
//        action.put("description","测试");//商品描述 非必填
//        //截图方式
//        action.put("shotType","ONESELF");//PZDS_OFFICIAL 盼之官方 ONESELF 自己上传
//        action.put("section2",5);//荣耀水晶数
//        action.put("section1",100);// 皮肤数
//        //1466金色仲夏夜1467幽冥之眼1468幽冥火1469幻海之心1470未来机甲1471零号雷霆1475时之愿境2560无
//        action.put("detailsCheckbox2",new Integer[]{1466,1467});
//        action.put("single4",2164);// 2164 可二次实名 2165 不可二次实名 2166 已删实名 2561 包人脸
//        //3514 皮肤1 3515皮肤2 3516皮肤3 3517皮肤4
//        action.put("detailsCheckbox1",new Integer[]{3514});//星元皮肤1
//        action.put("goodsCatalogueId",6);//商品分类id ,
//        action.put("gameId",7);//王者荣耀 7
//        action.put("linkPhone","13723456789");
//        action.put("linkQq","13723456789");
//        action.put("linkWx","13723456789");
//        action.put("compensation",false);//是否包赔
//        action.put("bargain",false);//是否接受砍价
//        action.put("outGoodsNo","255");//对接方商品编号（保持自有编号唯一）非必填
//        action.put("sellRange","ALL");//出售范围  ['ALL', 'ONLY_GAME', 'ONLY_GAME_NO_SAFE'],
//        action.put("single1","1121");
//        action.put("single2","1040");
//        action.put("detailsSingle1",1328);//1328无防沉迷 1329有防沉迷
//
//        params.put("action",action);
//        params.put("timestamp","1657380608115");
//        String cover = getCover(action);
//
//        cover = cover +  "timestamp=" + params.get("timestamp").toString() + "&key=pzds_open_api_sign_B45CFFE084DD3D20D928BEE85E7B0F21";
//        System.out.println("cover: "+cover);
//        String sign = DigestUtils.md5Hex(cover).toUpperCase();
//        params.put("sign",sign);
//        System.out.println(JSONObject.toJSONString(params));
//        String response = HttpUtils.sendPost(OutUrlConstant.PANZHIURL+"/openData/dataSync", JSONObject.toJSONString(params), "application/json");
//        System.out.println(response);

        //==================edit
//        Map<String,Object> action = new TreeMap<>();
//        action.put("outGoodsNo","255");
//        action.put("price",300);
//        action.put("remark","修改价格");
//        Map<String,Object> params = new HashMap<>();
//        params.put("proxyId",PZ_PROXY_ID);
//        params.put("action",action);
//        params.put("timestamp",System.currentTimeMillis()+"");
//
//        String cover = getCover(action) +"timestamp=" + params.get("timestamp").toString() + "&key=pzds_open_api_sign_B45CFFE084DD3D20D928BEE85E7B0F21";
//        String sign = DigestUtils.md5Hex(cover).toUpperCase();
//        params.put("sign",sign);
//
//        System.out.println(JSONObject.toJSONString(params));
//        String response = HttpUtils.sendPost(OutUrlConstant.PANZHIURL+"/openData/updateGoodsPrice", JSONObject.toJSONString(params), "application/json");
//        System.out.println(response);

//        //------del


        //获取游戏
//        {
//            "action": {
//            "proxyId": "string"
//        },
//            "proxyId": "string",
//                "sign": "string",
//                "timestamp": "string"
//        }

        //游戏属性
//        {
//            "action": {
//            "gameId": 0,
//                    "goodsCatalogueId": 0
//        },
//            "proxyId": "string",
//                "sign": "string",
//                "timestamp": "string"
//        }

        //获取操作系统-区-服树
//        {
//            "action": {
//            "gameId": 0,
//                    "goodsCatalogueId": 0
//        },
//            "proxyId": "string",
//                "sign": "string",
//                "timestamp": "string"
//        }


        //4.获取各个选项值
//        {
//            "action": {
//            "gameId": 0,
//                    "goodsCatalogueId": 0
//        },
//            "proxyId": "string",
//                "sign": "string",
//                "timestamp": "string"
//        }


//        逆战  14    火影  11 永劫 2

       // {"success":true,"code":"SUCCESS","info":"操作成功","data":[{"gameId":7,"gameName":"王者荣耀","goodsCatalogueId":6,"goodsCatalogueName":"账号"},{"gameId":8,"gameName":"和平精英","goodsCatalogueId":6,"goodsCatalogueName":"账号"},{"gameId":10,"gameName":"穿越火线-枪战王者","goodsCatalogueId":6,"goodsCatalogueName":"账号"},{"gameId":11,"gameName":"火影忍者","goodsCatalogueId":6,"goodsCatalogueName":"账号"},{"gameId":14,"gameName":"逆战","goodsCatalogueId":6,"goodsCatalogueName":"账号"},{"gameId":16,"gameName":"穿越火线","goodsCatalogueId":6,"goodsCatalogueName":"账号"}]}

        //{"success":true,"code":"SUCCESS","info":"操作成功","data":[{"gameId":16,"goodsCatalogueId":null,"propertyName":"游戏账号","mappingField":"gameAccount","required":true,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"游戏密码","mappingField":"gameSecret","required":true,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"账号来源","mappingField":"accountSource","required":false,"fieldType":"SINGLE"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"有无防沉迷","mappingField":"detailsSingle1","required":true,"fieldType":"SINGLE"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"是否可以二次实名","mappingField":"detailsSingle2","required":true,"fieldType":"SINGLE"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"商品标题","mappingField":"title","required":true,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"商品封面图","mappingField":"goodsImg","required":true,"fieldType":"IMAGE"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"截图备注","mappingField":"shotRemark","required":false,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"价格","mappingField":"price","required":true,"fieldType":"SECTION"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"详情图数组","mappingField":"detailsImages","required":true,"fieldType":"IMAGE"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"商品描述","mappingField":"description","required":false,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"截图方式","mappingField":"shotType","required":true,"fieldType":"SINGLE"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"能否排位","mappingField":"single4","required":true,"fieldType":"SINGLE"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"自行下架时间","mappingField":"oneselfDownStandTime","required":false,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"商品状态","mappingField":"status","required":false,"fieldType":"SINGLE"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"备注","mappingField":"remark","required":false,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"商品编号","mappingField":"goodsNo","required":false,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"强制下架原因","mappingField":"forceDownStandRemark","required":false,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"审核时间","mappingField":"verifyTime","required":false,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"商品分类id","mappingField":"goodsCatalogueId","required":true,"fieldType":"SINGLE"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"成交价","mappingField":"transactionPrice","required":false,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"商品热度","mappingField":"tempHeat","required":false,"fieldType":"SINGLE"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"上架时间","mappingField":"onStandTime","required":false,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"是否删除","mappingField":"del","required":false,"fieldType":"SINGLE"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"出售者id","mappingField":"sellerId","required":true,"fieldType":"SINGLE"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"外部对接商品编号","mappingField":"outGoodsNo","required":false,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"强制下架时间","mappingField":"forceDownStandTime","required":false,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"商品成交时间","mappingField":"transactionTime","required":false,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"号商标识","mappingField":"merchantMark","required":false,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"游戏id","mappingField":"gameId","required":true,"fieldType":"SINGLE"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"简要信息","mappingField":"simpleMessage","required":false,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"冗余搜索","mappingField":"searchField","required":false,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"是否顶级","mappingField":"top","required":false,"fieldType":"SINGLE"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"联系电话","mappingField":"linkPhone","required":true,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"联系QQ","mappingField":"linkQq","required":true,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"联系微信","mappingField":"linkWx","required":true,"fieldType":"TEXT"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"是否支持包赔","mappingField":"compensation","required":true,"fieldType":"SINGLE"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"是否接受砍价","mappingField":"bargain","required":true,"fieldType":"SINGLE"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"战区","mappingField":"single1","required":true,"fieldType":"SINGLE"},{"gameId":16,"goodsCatalogueId":null,"propertyName":"服务器","mappingField":"single2","required":true,"fieldType":"SINGLE"}]}

        Map<String,Object> action = new TreeMap<>();
        action.put("goodsCatalogueId",6);
        action.put("gameId",2);
        Map<String,Object> params = new HashMap<>();
        params.put("proxyId",PZ_PROXY_ID);
        params.put("action",action);
        params.put("timestamp",1658153198368L+"");

        String proxyKey = "pzds_open_api_sign_C7C97D5BC82A123F662ED84BBA5CC647";
//        String proxyKey = "pzds_open_api_sign_3430E933C35AD3AC1820D23485CBE64E";

        String cover = getCover(action) +"timestamp=" + params.get("timestamp").toString() + "&key=" + proxyKey;
        String sign = DigestUtils.md5Hex(cover).toUpperCase();
        System.out.println(sign);
        System.out.println(cover);
        params.put("sign",sign);
        System.out.println(JSONObject.toJSONString(params));
        String response = "";
         response = HttpUtils.sendPost(OutUrlConstant.PANZHIURL+"/api/openData/cooperateGameGoods", JSONObject.toJSONString(params), "application/json");
        System.out.println(response);
         response = HttpUtils.sendPost(OutUrlConstant.PANZHIURL+"/api/openData/getGameGoodsPropertyConfig", JSONObject.toJSONString(params), "application/json");
        System.out.println(response);
         response = HttpUtils.sendPost(OutUrlConstant.PANZHIURL+"/api/openData/listTreeProperty", JSONObject.toJSONString(params), "application/json");
        System.out.println(response);
         response = HttpUtils.sendPost(OutUrlConstant.PANZHIURL+"/api/openData/listPropertyOption", JSONObject.toJSONString(params), "application/json");
        System.out.println(response);
    }

}
